// 某个数`左边所有数字的和`等于`右边所有数字的和`，输出这个数，没有则返回-1

function fn(ary) {
    const left = [], right = []
    const len = ary.length
    for(let i = len - 1; i >= 0; i--) {
        right[i] = (right[i + 1] ? right[i + 1] : 0) + ary[i]
    }
    for(let i = 0; i < len; i++) {
        left[i] = (left[i - 1] ? left[i - 1] : 0) + ary[i]
        if (left[i - 1] && right[i + 1]&& left[i - 1] === right[i + 1]) {
            return i
        }
    }
    return -1
    // console.log(left, right)
}

console.log(fn([1, 2, 3, 0, 6]))